<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('admins', function (Blueprint $table) {
            $table->id();
            $table->string('name')->nullable()->comment('管理员名称');
            $table->string('phone', 20)->nullable()->unique()->comment('手机号码');
            $table->string('email')->nullable()->unique()->comment('邮箱');
            $table->string('avatar')->nullable()->comment('头像地址');
            $table->string('password')->comment('密码');
            $table->tinyInteger('status')->default(1)->comment('账号状态 0=禁用 1=启用');
            $table->boolean('is_super')->default(false)->comment('超级管理员');
            $table->timestamp('last_login_at')->nullable()->comment('最后登录时间');
            $table->ipAddress('last_login_ip')->nullable()->comment('最后登录IP');
            $table->rememberToken();
            $table->timestamps();
            $table->comment('后台管理员账户表');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('admins');
    }
};
